<?php
/**
 * TomatoCMS
 *
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 *
 * @copyright    Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license        http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version     $Id: add.phtml 3032 2010-05-25 08:00:42Z huuphuoc $
 */
?>
<?php
$this->headTitle($this->translator('enterprise_edit_enterprise_info_page_title'));

$this->headScript()
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.validate/jquery.validate.min.js')
    ;
?>
<?php
    $number = $this->number;
    $arrayTitle = array(
        '1' => 'Giới thiệu',
        '2' => 'Lịch sử',
        '3' => 'Định hướng',
        '4' => 'Chính sách',
        '5' => 'Quy mô doanh nghiệp'
    );

    $arrayTitleEN = array(
        '1' => 'About us',
        '2' => 'History',
        '3' => 'Development',
        '4' => 'Policies',
        '5' => 'Enterprise scale'
    );
?>
<div class="grid_12 t_a_ui_breadcrumb">
    <span><a href="<?php echo $this->url(array(), 'enterprise_enterprise_list'); ?>"><?php echo $this->translator('enterprise_list_breadcump'); ?></a></span>
    <span><?php echo $this->translator('enterprise_edit_enterprise_info_breadcump'); ?></span>
</div>

<div class="grid_12"><?php echo $this->flashMessenger(); ?></div>

<form method="post" action="<?php echo $this->url(array('enterprise_id' => $this->enterprise_id), 'enterprise_enterprise_info'); ?>/<?php echo $this->lang?>" id="editInfoForm">
<div class="grid_12 t_a_bottom"><?php echo $this->translator('enterprise_edit_guide'); ?></div>

<div class="grid_12 t_a_bottom">
    <div class="prefix_1 suffix_1">
        <?php if(!$this->isAllowed):?>
            <?php echo $this->translator('enterprise_not_edit_basic_guide'); ?>
        <?php else:?>
        <?php for($i=1;$i<=$number;$i++):?>
        <?php
            $item = isset($this->info[$i])?$this->info[$i]:null;
            $title = isset($item->info_title)?$item->info_title:$arrayTitle[$i];
            $string =  isset($item->info_string)?$item->info_string:null;
        ?>
        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_info_title').' '.$i; ?>:</label>
            <input type="text" readonly="true" id="info_title_<?php echo $i;?>" name="info_title_<?php echo $i;?>" style="width: 300px" value="<?php echo $title;?>" />
        </div>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('enterprise_info_string').' '.$i; ?>:</label>
            <textarea style="width:300px" rows="5" id="info_string_<?php echo $i;?>" name="info_string_<?php echo $i;?>"><?php echo $string;?></textarea>
        </div>

        <hr/>
        <?php endfor;?>

        <div class="clearfix t_a_bottom">
            <label>&nbsp;</label>
            <button type="submit"><span><?php echo $this->translator('enterprise_add_save_button'); ?></span></button>&nbsp;&nbsp;&nbsp;
            <button type="reset"><span><?php echo $this->translator('enterprise_reset_button'); ?></span></button>
        </div>
        <?php endif;?>
    </div>
</div>
</form>

<script type="text/javascript">

$(document).ready(function() {

    $('#editInfoForm').validate({
        rules: {
            <?php for($i=1;$i<=$number;$i++):?>
            info_title_<?php echo $i;?>: {
                required: true,
                maxlength: 255
            },
            <?php endfor;?>
        },
        messages: {
            <?php for($i=1;$i<=$number;$i++):?>
            info_title_<?php echo $i;?>: {
                required: "<?php echo $this->translator('enterprise_info_title_required'); ?>",
                maxlength: "<?php echo $this->translator('enterprise_info_title_maxlength'); ?>"
            },
            <?php endfor;?>
        }
    });
});
</script>
